//
//  ClubNetwork.m
//  Shengzhuli
//
//  Created by FXGuo on 2017/7/17.
//  Copyright © 2017年 kamangkeji. All rights reserved.
//

#import "ClubNetwork.h"
#import "GFXNetworkHandle.h"
#import "ImageTitleModel.h"
#import "AdderInfoModel.h"
#import "OldActivityModel.h"
#import "HomeYueModel.h"

NSString * const EditMyClub = @"auth/club/addImageDetail";//俱乐部添加
NSString * const MyClubModify = @"auth/club/editImageDetail";//俱乐部修改
NSString * const MyClubDetail = @"auto/club/detail";//俱乐部详情
NSString * const ClubImageTitleDetail = @"club/ImageDetail";//图文详情

NSString * const NearActivityList = @"club/activityList";//近期活动
NSString * const NearActivityAdd = @"auth/club/addOrEditClubActivity";//近期活动添加修改
NSString * const NearActivityDetail = @"club/activityDetail";//近期活动详情
NSString * const NearAcNewDetail = @"club/activityDetail/send";//新活动详情
NSString * const NearActivityAddCustomer = @"club/activity/registration/listpage";//近期活动报名
NSString * const NearActivityReport = @"auth/app/activityRegistration";//近期活动报名
NSString * const NearAcReportNum = @"club/activity/registration/number";//近期活动报名人数

NSString * const OldActivityList = @"information/list";//往期活动
NSString * const OldActivityPublic = @"information/add";//往期发布
NSString * const OldActivityDetail = @"information/detail/update";//往期咨询详情
NSString * const OldSelfActivityList = @"club/information/list";//俱乐部往期活动

NSString * const HomeDynamic = @"information/managerDynamic";//首页动态
NSString * const HomeYue = @"activity/list";//首页约么




@implementation ClubNetwork

+ (void)uploadClubInfoWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg))response
{
    [[GFXNetworkHandle shareHandle]post:EditMyClub params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            response(YES,json[@"message"]);
        }else{
            response(NO,json[@"message"]);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError);
    }];
}

+ (void)modifyClubInfoWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg))response
{
    [[GFXNetworkHandle shareHandle]post:MyClubModify params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            response(YES,json[@"message"]);
        }else{
            response(NO,json[@"message"]);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError);
    }];
}

+ (void)getMyClubDetailWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg,ClubModel *model))response
{
    [[GFXNetworkHandle shareHandle]post:MyClubDetail params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            ClubModel *model = [ClubModel objectWithDict:json[@"result"]];
            response(YES,json[@"message"],model);
        }else{
            response(NO,json[@"message"],nil);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError,nil);
    }];
}

+ (void)getClubImageTitleDetailWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg,NSArray *lists))response
{
    [[GFXNetworkHandle shareHandle]post:ClubImageTitleDetail params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            NSMutableArray *lists = [NSMutableArray array];
            for (NSDictionary *dict in json[@"result"]) {
                ImageTitleModel *model = [ImageTitleModel objectWithDict:dict];
                [lists addObject:model];
            }
            response(YES,json[@"message"],lists);
        }else{
            response(NO,json[@"message"],nil);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError,nil);
    }];
}

+ (void)getNearActivityListWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg,NSArray *lists))response
{
    [[GFXNetworkHandle shareHandle]post:NearActivityList params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            NSMutableArray *lists = [NSMutableArray array];
            for (NSDictionary *dict in json[@"result"]) {
                ActivityDetailModel *model = [ActivityDetailModel objectWithDict:dict];
                [lists addObject:model];
            }
            response(YES,json[@"message"],lists);
        }else{
            response(NO,json[@"message"],nil);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError,nil);
    }];
}
+ (void)getOldActivityListWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg,NSArray *lists))response
{
    [[GFXNetworkHandle shareHandle]post:OldActivityList params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            NSMutableArray *lists = [NSMutableArray array];
            for (NSDictionary *dict in json[@"result"]) {
                OldActivityModel *model = [OldActivityModel objectWithDict:dict];
                [lists addObject:model];
            }
            response(YES,json[@"message"],lists);
        }else{
            response(NO,json[@"message"],nil);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError,nil);
    }];
}

+ (void)getOldSelfActivityListWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg,NSArray *lists))response
{
    [[GFXNetworkHandle shareHandle]post:OldSelfActivityList params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            NSMutableArray *lists = [NSMutableArray array];
            for (NSDictionary *dict in json[@"result"]) {
                OldActivityModel *model = [OldActivityModel objectWithDict:dict];
                [lists addObject:model];
            }
            response(YES,json[@"message"],lists);
        }else{
            response(NO,json[@"message"],nil);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError,nil);
    }];
}

+ (void)nearActivityAddModifyWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg))response
{
    [[GFXNetworkHandle shareHandle]post:NearActivityAdd params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            response(YES,json[@"message"]);
        }else{
            response(NO,json[@"message"]);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError);
    }];
}

+ (void)nearActivityDetailWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg,ActivityDetailModel *model))response
{
    [[GFXNetworkHandle shareHandle]post:NearActivityDetail params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            ActivityDetailModel *model = [ActivityDetailModel objectWithDict:json[@"result"]];
            response(YES,json[@"message"],model);
        }else{
            response(NO,json[@"message"],nil);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError,nil);
    }];
}

+ (void)getNearAcNewDetailWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg,ActivityDetailModel *model))response
{
    [[GFXNetworkHandle shareHandle]post:NearAcNewDetail params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            ActivityDetailModel *model = [ActivityDetailModel objectWithDict:json[@"result"]];
            response(YES,json[@"message"],model);
        }else{
            response(NO,json[@"message"],nil);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError,nil);
    }];
}

+ (void)getNearAdderListWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg,NSArray *lists))response
{
    [[GFXNetworkHandle shareHandle]post:NearActivityAddCustomer params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            NSMutableArray *lists = [NSMutableArray array];
            for (NSDictionary *dict in json[@"result"]) {
                AdderInfoModel *model = [AdderInfoModel objectWithDict:dict];
                [lists addObject:model];
            }
            response(YES,json[@"message"],lists);
        }else{
            response(NO,json[@"message"],nil);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError,nil);
    }];
}

+ (void)nearActivityReportWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg))response
{
    [[GFXNetworkHandle shareHandle]post:NearActivityReport params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            response(YES,json[@"message"]);
        }else{
            response(NO,json[@"message"]);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError);
    }];
}

+ (void)oldActivityAddModifyWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg))response
{
    [[GFXNetworkHandle shareHandle]post:OldActivityPublic params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            response(YES,json[@"message"]);
        }else{
            response(NO,json[@"message"]);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError);
    }];
}

+ (void)oldActivityDetailWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg,OldActivityDetailModel *model))response
{
    [[GFXNetworkHandle shareHandle]post:OldActivityDetail params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            OldActivityDetailModel *model = [OldActivityDetailModel objectWithDict:json[@"result"]];
            response(YES,json[@"message"],model);
        }else{
            response(NO,json[@"message"],nil);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError,nil);
    }];
}

+ (void)getDynamicWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg,NSArray *lists))response
{
    [[GFXNetworkHandle shareHandle]post:HomeDynamic params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            NSMutableArray *lists = [NSMutableArray array];
            for (NSDictionary *dict in json[@"result"]) {
                OldActivityModel *model = [OldActivityModel objectWithDict:dict];
                [lists addObject:model];
            }
            response(YES,json[@"message"],lists);
        }else{
            response(NO,json[@"message"],nil);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError,nil);
    }];
}

+ (void)getHomeYueParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg,NSArray *lists))response
{
    [[GFXNetworkHandle shareHandle]post:HomeYue params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            NSMutableArray *lists = [NSMutableArray array];
            for (NSDictionary *dict in json[@"result"]) {
                HomeYueModel *model = [HomeYueModel objectWithDict:dict];
                [lists addObject:model];
            }
            response(YES,json[@"message"],lists);
        }else{
            response(NO,json[@"message"],nil);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError,nil);
    }];
}

+ (void)getNearAcNumWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg,NSInteger num))response
{
    [[GFXNetworkHandle shareHandle]post:NearAcReportNum params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            response(YES,json[@"message"],[json[@"result"][@"registrationNumber"] integerValue]);
        }else{
            response(NO,json[@"message"],0);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError,0);
    }];
}

@end
